var status = -1;
var selectionLog = [];

function start() {
    action(1, 0, 0)
}

function action(d, c, b) {
    if (status == 0 && d == 0) {
        cm.dispose();
        return
    }
    status++;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        cm.dispose()
    } else {
        if (status === a++) {
            cm.getPlayer().removeFamiliar();
            cm.closeUI(596);
            if (cm.isQuestActive(64760)) {
                cm.dispose();
                cm.warp(867147002, 0, true);
                return
            }
            if (cm.isQuestFinished(64760)) {
                cm.npc_ChangeController(9401029, "oid=8634112", 408, 20, 137, 358, 458, 1, true, 0, false);
                cm.npc_SetSpecialAction("oid=8634112", "summon", 0, 0);
                cm.npc_ChangeController(9401035, "oid=8634113", -7, -70, 131, -57, 43, 1, true, 0, false);
                cm.npc_SetSpecialAction("oid=8634113", "summon", 0, 0);
                cm.npc_ChangeController(9401049, "oid=8634114", -263, 130, 122, -313, -213, 0, true, 0, false);
                cm.npc_SetSpecialAction("oid=8634114", "summon", 0, 0)
            }
            cm.curNodeEventEnd(true);
            cm.eventSKill(0);
            cm.setInGameDirectionMode(true, false, true);
            cm.fieldEffect_InsertCanvas(1, 255, 0, 0, 0, 0, 0);
            cm.inGameDirectionEvent_AskAnswerTime(300);
            cm.curNodeEventEnd(true)
        } else {
            if (status === a++) {
                cm.fieldEffect_InsertCanvas(0, 0, 0, 0, 0, 1000, 0);
                cm.inGameDirectionEvent_AskAnswerTime(1000)
            } else {
                if (status === a++) {
                    cm.eventSKill(0);
                    cm.setInGameDirectionMode(false, true, false);
                    if (cm.getQuestStatus(64762) > 0) {
                        cm.openNewUI(1, "UIAbyssExpeditionManangementButton");
                        cm.fakeInit()
                    }
                    cm.dispose()
                }
            }
        }
    }
};